import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {ValidateProvider} from "../../providers/validate/validate";

@IonicPage({
    segment: 'member/bond/refund/result',
    defaultHistory:['PersonBondPage']
})
@Component({
    selector: 'page-bond-refund-result',
    templateUrl: 'bond-refund-result.html',
})
export class BondRefundResultPage {
    error: number;
    message: string;

    constructor(
        public navCtrl: NavController,
        public navParams: NavParams,
        public validate: ValidateProvider
    ) {
    }

    ionViewCanEnter(){
        return this.validate.checkLogin();
    }

    ionViewWillEnter(){
        this.error = this.navParams.get('error');
        if (this.error === 200) {
            this.message = "保证金退还到余额成功";
        } else if(this.error == 300) {
            this.message = "您当前还有正在进行的悬赏任务，暂时无法退还保证金";
        }else{
            this.message = "保证金退还到余额失败";
        }
    }

    finish() {
        this.navCtrl.popToRoot({
            animate: true,
            direction: 'forward'
        });
    }
}
